package org.squabble.dao;

import java.util.List;

import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.squabble.domain.Flag;

@Repository
public class FlagDAOImpl extends AbstractHibernateDAO<Flag> implements FlagDAO {

	@Autowired
	public FlagDAOImpl(SessionFactory sessionFactory) {
		super(Flag.class, sessionFactory);
	}

	@Override
	public List<Flag> getUserSelectableFlags() {
		return list(criteria().add(Restrictions.eq("userSelectable", true))
				.addOrder(Order.asc("name")));
	}

	@Override
	public Flag loadFlag(Long id) {
		return load(id);
	}

}
